import time,random
def get_tracks(distance):
    distance = int(distance) + 8
    trace = []
    first_time = int(time.time()*1000)
    trace.append(["1137","342",first_time])
    trace.append(["1166","342",first_time])
    slide_trace = distance/5
    slide_trace_1 = slide_trace
    distance_1 = distance

    # 设置初始位置、初始速度、时间间隔
    start, v0, t = 1166, 1.25, random.randint(7, 11)/10
    start_1 = start
    first_distance = start + int(distance * 2 / 5)
    last_distance = start + int(distance *4 / 5)
    print(first_distance,last_distance)

    # 当尚未移动到终点时
    while start < first_distance:
        distance = distance - v0 * t
        move = start + v0 * t
        start = start + v0 * t
        trace.append([str(round(move)), "383", int(first_time + t * 10)])
        first_time = first_time + t * 10
    while first_distance<=start < last_distance:
        v0 = 1.3
        t = random.randint(13, 16)/10
        distance = distance - v0 * t
        move = start + v0 * t
        start = start + v0 * t
        trace.append([str(round(move)), "384", int(first_time + t * 10)])
        first_time = first_time + t * 10
    while start_1+distance_1>= start >=last_distance:
        v0 = 1.25
        t = random.randint(7, 11)/10
        # if distance<=0:
        #     print(True)
        #     trace.append([str(start_1 + distance), "385", int(trace[-1][2] + random.randint(2000,10000))])
        #     print(trace[-1])
        #     if trace[-2][0] != trace[-1][0]:
        #         trace[-2][0] = trace[-1][0]
        #     return trace
        # if distance <= 0:
        #     return trace
        # print(distance)
        distance = distance - v0 * t
        move = start + v0 * t
        start = start + v0 * t
        trace.append([str(int(round(move))),"385",int(first_time+ t * 10)])
        first_time = first_time + t * 10
    # 继续滑动五分之一然后在滑动回来
    while start<= start_1+distance_1+slide_trace:
        # print('五分之一后的:',start)
        v0 = 1.25
        t = random.randint(7, 11)/10
        # slide_trace_1 = slide_trace_1 - v0 * t
        move = start + v0 * t
        start = start + v0 * t
        trace.append([str(int(round(move))),"385",int(first_time+ t * 10)])
        first_time = first_time + t * 10
    while start > start_1+distance_1:
        v0 = -1.25
        t = random.randint(7, 11)/10
        move = start + v0 * t
        start = start + v0 * t
        if start == start_1 + distance:
            print('1111')
            return trace
        if start <= start + distance:
            print('最后一次的',start)
            return trace
        trace.append([str(round(move)),"385",int(first_time+ t * 10)])
        first_time = first_time + t * 10
    trace.append([str(trace[-1][0]),'385',int(trace[-1][2] + random.randint(2000,10000))])
    return trace
